﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TireService.Data
{
    public partial class Container
    {
        TireServiceDB db = new TireServiceDB();

        /// <summary>
        /// Validation rules to ensure data is filled out in mandatory fields
        /// </summary>
        partial void OnValidate(System.Data.Linq.ChangeAction action)
        {

        }

        partial void OnInActiveChanging(bool value)
        {
            if (value == true)
            {
                // Check that no wheels are stored in container
                if (db.GetContainerUsedCapacity(this.ContainerId).Single().UsedCapacity > 0)
                {
                    throw new ArgumentException("Lager/container kan ikke deaktiveres pga. der ligger hjul på lager. Venligst flyt disse inden deaktivering.");
                }
            }
        }
    }
}
